﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace HYCodeBase.WinForm.BackGroundProgressBar
{
	internal partial class ProgressBarForm : System.Windows.Forms.Form
	{
		public bool IfCanClose
		{
			get
			{
				bool bIfCanClose;
				lock (this)
				{
					bIfCanClose = this.m_bIfCanClose;
				}
				return bIfCanClose;
			}
			internal set
			{
				lock (this)
				{
					this.m_bIfCanClose = value;
				}
			}
		}

		internal ProgressBarForm(ProgressBarManger inputManger)
		{
			this.m_useManger = inputManger;
			this.InitializeComponent();
		}

		private void ProcessBarForm_Load(object sender, EventArgs e)
		{
			this.pB_useProgressBar.MarqueeAnimationSpeed = 20;
			this.pB_useProgressBar.Style = ProgressBarStyle.Marquee;
		}

		protected override bool ProcessKeyEventArgs(ref Message m)
		{
			int num = 256;
			int num2 = 27;
			if (m.Msg == num && m.WParam.ToInt32() == num2)
			{
				base.Close();
			}
			return base.ProcessKeyEventArgs(ref m);
		}

		private void ProcessBarForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (!this.IfCanClose)
			{
				this.m_useManger.AbsortThread();
			}
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private bool m_bIfCanClose;

		private ProgressBarManger m_useManger;
	}
}
